package b_state.b_design_patten;

/**
 * Created by wug on 2016/6/14 0014.
 */
public class StateNoMoney implements State {
    WaterMachine waterMachine;

    public StateNoMoney(WaterMachine waterMachine) {
        this.waterMachine = waterMachine;
    }

    @Override
    public void workerPut() {
        waterMachine.setState(new StateSoldOut(waterMachine));
        waterMachine.put();
    }

    @Override
    public void insertMoney(int num) {
        waterMachine.setMoney(waterMachine.getMoney() + num);
        waterMachine.setState(new StateHaveMoney(waterMachine));
        System.out.println("投入" + num + "元钱，售水机中有" + waterMachine.getMoney() + "元钱!");
    }

    @Override
    public void pressSellBtn() {
//        waterMachine.setState(new StateLucky(waterMachine));
        waterMachine.setState(new StateSold(waterMachine));
        waterMachine.sell();
    }

    @Override
    public void refundRocker() {
        waterMachine.setState(new StateHaveMoney(waterMachine));
        waterMachine.retun();
    }
}
